<template>
  <div class="app-container home">
    <div class="summary-box">
      <div v-for="(item, index) in summaryList" :key="index">
        <div :style="{ background: item.bgColor }">
          <img :src="require(`@/assets/images/index_page/${item.img}`)" />
        </div>
        <div>
          <div class="title">{{ item.title }}</div>
          <div class="line" :style="{ background: item.labelColor }"></div>
          <div class="count">
            <div>
              <span>本月统计量</span>
              <countTo :style="{ color: item.labelColor }" :endVal="item.monthCnt"></countTo>
            </div>
            <div>
              <span>当年统计量</span>
              <countTo :style="{ color: item.labelColor }" :endVal="item.yearCnt"></countTo>
            </div>
          </div>
        </div>
      </div>
    </div>
    <el-row class="home-rowheight">
      <el-col :span="24">
        <div class="home-col-item">
          <div class="home-item-title">
            <span>政务类本月分类数量统计</span>
            <!-- <span style="float: right; font-size: 12px; font-family: 宋体; height: 40px; line-height: 40px; padding-right: 20px; cursor: pointer; color: #797b80">
              <el-date-picker v-model="yearStatisYear" :clearable="false" :editable="false" placeholder="选择年" size="mini" style="width: 120px" type="year" value-format="yyyy" />
            </span> -->
            <!-- <span style="float: right; font-size: 12px; font-family: 宋体; height: 40px; line-height: 40px; padding-right: 20px; cursor: pointer; color: #797b80">统计年份</span> -->
          </div>
          <lettersByType />
        </div>
      </el-col>
      <el-col :span="24">
        <div class="home-col-item">
          <div class="home-item-title">信访类本月分类数量统计</div>
          <matterByMonth />
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
//	import { initTopUserList } from "@/api/system/homepage";
//import Util from '@/utils/activiti/myUtil'
import lettersByType from "@/views/hades/homepage/lettersByType"; // 上1
import matterByMonth from "@/views/hades/homepage/matterByMonth"; // 上2
import countTo from "vue-count-to";
import { getHomePageSummary } from "@/api/hades/index/report";

export default {
  name: "Boardindex",
  components: {
    lettersByType,
    matterByMonth,
    countTo,
  },
  data() {
    return {
      rowWidth: "300px",
      summaryList: [
        { id: 1, title: "政务服务热线服务平台", bgColor: "linear-gradient(-42deg, #458CE9, #2A83FF, #2E85FF)", labelColor: "#2E85FF", monthCnt: 20, yearCnt: 20, img: "icon1.png" },
        { id: 2, title: "省住建厅官网厅长信箱", bgColor: "linear-gradient(-42deg, #6AE9CF, #4BD5B8, #37C1A5)", labelColor: "#37C1A5", monthCnt: 30, yearCnt: 30, img: "icon2.png" },
        { id: 3, title: "人民网领导留言板", bgColor: "linear-gradient(-42deg, #4BD5B8, #5BB7DE)", labelColor: "#3BA2CD", monthCnt: 0, yearCnt: 0, img: "icon3.png" },
        { id: 4, title: "来信事项登记", bgColor: "linear-gradient(-42deg, #F0A50C, #F0A40B)", labelColor: "#F0A40B", monthCnt: 0, yearCnt: 0, img: "icon4.png" },
        { id: 5, title: "来电事项登记", bgColor: "linear-gradient(-42deg, #2A83FF, #00C5FF, #00C5FF)", labelColor: "#00C5FF", monthCnt: 0, yearCnt: 0, img: "icon5.png" },
        { id: 6, title: "来访事项登记", bgColor: "linear-gradient(-42deg, #66C236, #65C134)", labelColor: "#65C134", monthCnt: 0, yearCnt: 0, img: "icon6.png" },
        { id: 7, title: "省信访局网络来件", bgColor: "linear-gradient(-42deg, #6AE9CF, #4BD5B8, #37C1A5)", labelColor: "#4DC5AC", monthCnt: 0, yearCnt: 0, img: "icon7.png" },
        { id: 8, title: "省信访局各地市信访件", bgColor: "linear-gradient(-42deg, #458CE9, #2A83FF, #2E85FF)", labelColor: "#2E85FF", monthCnt: 0, yearCnt: 0, img: "icon8.png" },
      ],
    };
  },
  created() {
    // 初始化供应商注册数据
    this.initTopUserData();
  },
  methods: {
    /** 供应商注册数据初始化 */
    initTopUserData() {
      getHomePageSummary().then((response) => {
        this.summaryList.forEach((v, idx) => {
          response.data.forEach((r) => {
            if (v.id === r.id) {
              v.yearCnt = r.yearCnt;
              v.monthCnt = r.monthCnt;
            }
          });
        });
      });
    },
    goTarget(href) {
      window.open(href, "_blank");
    },
  },
};
</script>
<style scoped lang="scss">
.app-container {
  padding: 10px !important;
}
.home {
  background: #f5f5f5;
  height: calc(100vh - 100px);
  .home-rowheight {
    height: calc(50vh - 70px);
  }
  .home-col-item {
    background: #ffffff;
    height: calc(50vh - 80px);
    margin: 10px;
    border-radius: 5px;
  }
  .home-item-title {
    padding: 10px 0 10px 10px;
    color: #333;
    font-size: 16px;
    font-weight: bold;
    .home-item-title-first {
      padding: 10px 0 10px 10px;
      color: #666666;
      font-size: 18px;
      font-weight: bold;
      z-index: 999;
      background: #ffffff;
      position: relative;
    }
    .home-item-content {
      width: 100%;
      top: -40px;
    }
    .home-scrollbar {
      height: calc(50vh - 120px);
      overflow: hidden;
      z-index: 100;
    }
  }
}
.summary-box {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  padding: 10px;
  & > div {
    display: flex;
    width: calc((100% - 60px) / 4);
    height: 160px;
    margin-bottom: 20px;
    border-radius: 5px;
    overflow: hidden;
    & > div:nth-child(1) {
      display: flex;
      align-items: center;
      justify-content: center;
      width: 33%;
      & > img {
        width: 55%;
      }
    }
    & > div:nth-child(2) {
      display: flex;
      flex-direction: column;
      align-items: center;
      width: 67%;
      padding: 16px;
      background: white;
      & > .title {
        font-weight: bold;
        font-size: 18px;
        color: #333333;
      }
      & > .line {
        width: 95%;
        height: 2px;
        margin: 18px 0;
      }
      & > .count {
        display: flex;
        width: 80%;
        justify-content: space-between;
        & > div {
          display: flex;
          flex-direction: column;
          align-items: center;
          & > span:nth-child(1) {
            font-family: Microsoft YaHei;
            font-weight: 400;
            font-size: 14px;
            color: #333333;
          }
          & > span:nth-child(2) {
            font-family: D-DIN;
            font-weight: 400;
            font-size: 36px;
          }
        }
      }
    }
  }
}
</style>
